﻿//======================================================================
//
//	Cross-Platform XNA Menu System
//  http://cpxms.codeplex.com/
//
//  All code and content licensed under Microsoft Public License (Ms-PL)	
//
//======================================================================
//
//	File:		Text.cs
//
//	Author:		MJP
//
//	Date:		04/27/09
//
//======================================================================

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.ComponentModel;
using System.Collections.ObjectModel;
using System.Xml.Serialization;
using System.Drawing.Design;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

namespace CPXMenu
{
	/// <summary>
	/// A MenuItem that draws string text using a SpriteFont
	/// </summary>
    [CanHaveChildren(false)]
    [IconKey("Label")]
    [Selectable(true)]
    [Movable(true)]
    [Sizeable(true)]
    [CanCopyPaste(true)]
    [Description("A MenuItem that draws string text using a SpriteFont")]
    public class Label : MenuItem
    {
        private TextState textState = new TextState();

		/// <summary>
		/// Gets or sets the text and font settings for teh label
		/// </summary>
        [Browsable(true)]
        [Category("Appearance")]
        [Description("The text and font settings for the label")]
        public TextState Text
        {
            get { return textState; }
            set
            {
                textState = value;
                TextStates.Clear();
                TextStates.Add(textState);
            }
        }


		/// <summary>
		/// Creates a new Label instance
		/// </summary>
        public Label()
            : base()
        {
            Dimensions = new Point(200, 50);

            Text = textState;
            TextStateIndex = 0;
        }

        /// <summary>
        /// Creates a clone of the item
        /// </summary>
        /// <returns>A clone of the item</returns>
        public override MenuItem Clone()
        {
            Label clone = (Label)base.Clone();

            clone.textState = this.textState.Clone();
            clone.TextStates.Add(clone.textState);

            return clone;
        }
    }
}